export default {
	findByKey(array, key){
		for (var index = 0; index < array.length; index++) {
			var item = array[index]
			//console.log("item=>" + JSON.stringify(item) + " item.key" + item.key + "--->" + key);
			if (item.key == key) {
				return item
			}
		}
	},
	findById(array, id){
		for (var index = 0; index < array.length; index++) {
			var item = array[index]
			if (item.id == id) {
				return item
			}
		}
	},
	findIndexByKey: function(array, key) {
		for (var index = 0; index < array.length; index++) {
			var item = array[index]
			if (item.key == key) {
				return index
			}
		}
		return -1
	},
	
	findIndexById: function(array, id) {
		for (var index = 0; index < array.length; index++) {
			var item = array[index]
			if (item.id == id) {
				return index
			}
		}
		return -1
	},
	
	deleteByIndex: function(array, index) {
		if(index < array.length){
			array.splice(index, 1)
			return 1
		} else {
			return -1
		}
	}
}
